hvm/load: correct length checks for zeroextended records
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 27 Oct 2014 15:41:50 +0000 (16:41 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 27 Oct 2014 15:41:50 +0000 (16:41 +0100)
commit66d0c0aa1f3e57e873fd64d1d370e11758d25442
treed79605c375e6813738c35652bf79124e9802ef61
parent607e8494c42397fb249191904066cace6ac9a880
hvm/load: correct length checks for zeroextended records

In the case that Xen is attempting to load a zeroextended HVM record where the
difference needing extending would overflow the data blob, _hvm_check_entry()
will incorrectly fail before working out that it would have been safe.

The "len + sizeof(*d)" check is wrong.  Consider zeroextending a 16 byte
record into a 32 byte structure.  "32 + hdr" will fail the overall context
length check even though the pre-extended record in the stream is 16 bytes.

The first condition is reduced to just a length check for hvm save header,
while the second condition is extended to include a check that the record in
the stream not exceeding the stream length.

The error messages are extended to include further useful information.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <Paul.Durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/hvm/save.c